/** 
 * All Rights Reserved , Copyright (C) 2023 , 青岛鼎信通讯股份有限公司
 * 
 *AppMessagePushController
 * APP推送消息
 * 
 * 修改纪录
 * 2023-09-09 版本：1.0 yanshunkuan 创建。
 * @version 版本：1.0
 * @author 作者：yanshunkuan
 * 创建日期：2023-09-09
 */

package com.topscomm.appv2.controller;

import com.topscomm.appv2.controller.auto.AppMessagePushControllerAuto;
import com.topscomm.basic.util.SQLAdapter;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: yanshunkuan
 * @date: 2023-09-09
 * @description:APP推送消息Controller
 * @modify:
 */
@RestController
@RequestMapping("appv2/appMessagePush")
public class AppMessagePushController extends AppMessagePushControllerAuto implements IAppMessagePushController {
	/**
	 * @author: yanshunkuan
	 * @date: 2023-09-09
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
    @Override
    protected String spellListSql(Map paraMap) {
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" 1=1 ");
        if (paraMap.containsKey("qry_receivercode")) {
            String value = paraMap.get("qry_receivercode").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and receivercode = {0} ", value);
        }
        if (paraMap.containsKey("qry_createon1")) {
            String value = paraMap.get("qry_createon1").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and createon >={0}", SQLAdapter.toDateLong(value + " 00:00:00"));
        }
        if (paraMap.containsKey("qry_createon2")) {
            String value = paraMap.get("qry_createon2").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and createon <={0}", SQLAdapter.toDateLong(value + " 23:59:59"));
        }
        if (paraMap.containsKey("qry_senddate1")) {
            String value = paraMap.get("qry_senddate1").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and senddate  >={0}", SQLAdapter.toDateLong(value + " 00:00:00"));
        }
        if (paraMap.containsKey("qry_senddate2")) {
            String value = paraMap.get("qry_senddate2").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and senddate <={0}", SQLAdapter.toDateLong(value + " 23:59:59"));
        }
        if (paraMap.containsKey("qry_content")) {
            String value = paraMap.get("qry_content").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and content like '%{0}%' ", value);
        }
        if (paraMap.containsKey("qry_state")) {
            String value = paraMap.get("qry_state").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and state = {0} ", value);
        }
        if (paraMap.containsKey("qry_messagetype")) {
            String value = paraMap.get("qry_messagetype").toString();
            if (!StringUtil.isEmpty(value))
                sql.appendSingle(" and messagetype = '{0}' ", value);
        }
        return sql.toString();
    }
}

